<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ page import="cn.edu.stu.getuserinfo.SNSUserInfo,java.lang.*"%>
<%@ page import="java.io.*,java.util.*" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<% 
	// 获取由OAuthServlet中传入的参数
	SNSUserInfo user = (SNSUserInfo)request.getAttribute("snsUserInfo"); 

	// 获取session创建时间
	Date createTime = new Date(session.getCreationTime());
	
	// 获取最后访问页面的时间
	Date lastAccessTime = new Date(session.getLastAccessedTime());
	
	if(null != user) {
		int count = 0;
		if (session.isNew()){
			session.setAttribute("openID", user.getOpenId());
			session.setAttribute("nickName", user.getNickname());
			session.setAttribute("sex", user.getSex());
			session.setAttribute("country", user.getCountry());
			session.setAttribute("province", user.getProvince());
			session.setAttribute("city", user.getCity());
			session.setAttribute("headImgUrl", user.getHeadImgUrl());
			session.setAttribute("privilegeList", user.getPrivilegeList());
		}
	}else{ 
		out.print("用户不同意授权,未获取到用户信息！");
	}
%>
<html>
<head>
    <title>OAuth2.0网页授权</title>
    <meta name="viewport" content="width=device-width,user-scalable=0">
</head>
<body>
	<jsp:forward page="/activity.do" />   
</body>
</html>